<?php

class ProcedureMail extends Swift_Message {
  
  public function __construct(sfContext $context, Procedure $procedure, $amount) {
    parent::__construct();
    
    $subject = '[Bundeslager 2013 | Anmeldung] Deine Buchung wurde gespeichert!';
    
    $message_parameters = array(
      'profile' => $procedure->getUserProfile(),
      'participants' => $procedure->getParticipants(),
      'tents' => $procedure->getTents(),
      'booking' => $procedure->getBooking(),
      'password' => ($procedure->isFirstTime() ? $procedure->getPassword() : false),
      'amount' => $amount
    );
    $context->getConfiguration()->loadHelpers('Partial');
    $message = get_partial('procedure/mail', $message_parameters);
    
    $this->setSubject($subject);
    $this->setBody($message);
    $this->setFrom(array(sfConfig::get('app_email_sender') => 'Falkenhorst'));
    $this->setTo($procedure->getUserProfile()->getEmailAddress());
  }
}